Skip to content

docs: add FilterState typedef and annotate filter-passing functions#39

Merged
mekarpeles merged 2 commits intomainfrom
docs/filterstate-typedef
Apr 27, 2026
Merged

docs: add FilterState typedef and annotate filter-passing functions#39
mekarpeles merged 2 commits intomainfrom
docs/filterstate-typedef

Conversation

@mekarpeles
Copy link
Copy Markdown
Member

Closes #35

What

Adds @typedef {Object} FilterState to utils/filters.js with a @property line for each of the seven filter fields and their accepted value ranges. Annotates buildChips and buildSearchParams with @param {FilterState} and @returns.

Why

The filter object is the primary data structure passed between ol-search-bar, ol-search-page, and the utils layer. Without a typedef, editors give no autocomplete or type errors when callers pass the wrong shape. New contributors have to read all consumers to discover what keys exist.

Verified by

Four new static-analysis tests in filters.test.js:

  • @typedef {Object} FilterState exists in the source
  • All 7 fields have @property entries
  • At least 2 @param {FilterState} annotations exist (buildChips + buildSearchParams)

No behavioral changes — 170 tests pass, lint clean.

closes #35

Adds a @typedef {Object} FilterState in utils/filters.js documenting all
seven fields (sort, availability, fictionFilter, languages, genres, authors,
subjects) with accepted value ranges. Annotates buildChips and
buildSearchParams with @param {FilterState} and @returns.

Four static-analysis tests verify the typedef and annotations exist so
they stay in sync if the filter shape changes.
Copilot AI review requested due to automatic review settings April 26, 2026 22:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds JSDoc typing for the shared “filter state” object to improve editor IntelliSense and documentation around filter-related utilities.

Changes:

  • Introduces a FilterState JSDoc typedef in frontend/src/utils/filters.js describing the 7 filter fields.
  • Annotates buildChips and buildSearchParams with @param {FilterState} (and adds @returns).
  • Adds Vitest “static analysis” tests that assert the typedef and key annotations exist in the source.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
frontend/src/utils/filters.js Adds FilterState typedef and JSDoc annotations for filter utility functions.
frontend/src/utils/filters.test.js Adds static-analysis tests that regex-check the presence of typedef and annotations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/utils/filters.test.js
Comment thread frontend/src/utils/filters.test.js
Comment thread frontend/src/utils/filters.js Outdated
Comment thread frontend/src/utils/filters.js Outdated
- FilterState @Property annotations now use JSDoc string-literal unions
  for sort/availability/fictionFilter and mark array fields as optional
  ([languages], [genres], [authors], [subjects]) to match runtime usage
- buildChips docstring corrected: availability and fiction chips use
  plain descriptive labels, not "type: value" prefix (only lang/genre/
  author/subject use the prefix)
- Added a 4th static-analysis test verifying literal-union types are
  present in the FilterState typedef
@mekarpeles mekarpeles merged commit a3a2575 into main Apr 27, 2026
2 checks passed
@mekarpeles mekarpeles deleted the docs/filterstate-typedef branch April 27, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add FilterState typedef and annotate all filter-passing functions

2 participants